<?php 
echo $this->Html->script('jquery');
echo $this->Html->script('common');

?>

<style type="text/css">
#fbactivities{
	font-family:"lucida grande",tahoma,verdana,arial,sans-serif;
	color:gray;
	font-size: 11px;
    line-height: 2;
}
#fbactivities a,a:visited{
	color:#3B5998;
	text-decoration:none;
}
#fbactivities a:hover{
	color:#3B5998;
	text-decoration:underline;
}
</style>
<div id="fbactivities">
<div style="font-size:16px;font-weight: bold;color:black">Những hoạt động gần đây của bạn</div>
<?php if(isset($data) && count($data)>0){
	foreach($data as $k=>$v){
		?>
<div id="article_<?php echo $k?>">
<div style="float:left;width:450px"><a href="<?php echo $v['url']?>" target="_blank"><?php echo $v['title']?></a></div><div style="float:left;width:20px;text-align:right"><a href="javascript:;" onclick="deleteactivity('<?php echo $k?>');">x</a></div>
<div style="clear:both"></div>
</div>
		<?php 
	}
	?>

<?php }?>
</div>

<script type="text/javascript">

//facebook
//for fb
var accessToken;
var uid;
  window.fbAsyncInit = function() {
      FB.init({
        appId      : '204609776328294', // App ID
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        xfbml      : true  // parse XFBML
      });

  
      
      FB.getLoginStatus(function(response) {
  		  if (response.status === 'connected') {
  		    // the user is logged in and has authenticated your
  		    // app, and response.authResponse supplies
  		    // the user's ID, a valid access token, a signed
  		    // request, and the time the access token 
  		    // and signed request each expire
  		    uid = response.authResponse.userID;
  		    accessToken = response.authResponse.accessToken;
  		    //call ajax show user config on this app
  		    $('#fbstatus').load('<?php echo $this->Seo->link('/fbs/loaduserdata');?>'+'/'+uid);
  		    
  		  	
  		  } else if (response.status === 'not_authorized') {
  		    // the user is logged in to Facebook, 
  		    // but has not authenticated your app
    		    
  		  } else {
  		    // the user isn't logged in to Facebook.
  		  }
  		 });

      

      
    };

   
    (function(d){
        var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        d.getElementsByTagName('head')[0].appendChild(js);
      }(document));
   function deleteactivity(id){
	   FB.api(
		        'https://graph.facebook.com/'+id+'?access_token='+accessToken+'&method=delete',
		        'GET',
		        { method:'delete' },
		        function(response) {
		           if (!response || response.error) {
		              printObject(response.error);
		           } else {
			           $('#article_'+id).remove();
		           }
		        });
	}

</script>